#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <cstring>
#include <cstdlib>
#include <string>
#include <time.h>

using namespace boost::interprocess;

int main()
{
	shared_memory_object shm(open_only, "Dados", read_write);

	mapped_region regionCaras(shm, read_write, 0, sizeof(int));
	mapped_region regionTiradas(shm, read_write, 0, sizeof(int));
	mapped_region regionEstado(shm, read_write, 0, sizeof(int));

	srand (time(NULL));

	while (true)
	{
		int state = *(static_cast<int*>(regionEstado.get_address()));
		
		if (state == 0)
		{
			int caras = rand() % 17 + 4;
			*(int*)(regionCaras.get_address()) = caras;

			int tiradas = rand() % 10 + 1;
			*(int*)(regionTiradas.get_address()) = tiradas;

			*(int*)(regionEstado.get_address()) = 1;
		}
		else if (state == 1)
		{
		}
	}

	return 1;
}